﻿using System;
using System.Web;
using System.Web.Routing;
using ECube.Web.CMS.Models;
using ECube.Web.CMS;
namespace ECube.Web.CMS.Routing
{
    
    public class IsSitePageMode : IRouteConstraint
    {
        private readonly  PageMode mode;
        public IsSitePageMode(PageMode mode)
        {
            this.mode = mode;
        }
        public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection)
        {
            
            string pagePath = httpContext.Request.RawUrl;//values[parameterName] != null ? values[parameterName].ToString() : "";

            if (pagePath.EndsWith("?" + mode, StringComparison.OrdinalIgnoreCase))
            {
                return true;
            }
            return false;
        }
    }
}
